<?php
class moduleconf
{
	public $table;
	public $pages;
	public $db;

	function moduleconf()
	{
		global $db;
        $this->db = &$db;
        $this->table = DB_PRE.'module_conf';
	}
	
	function get_conf($module, $catid)
	{
		$this->db->prepare('select * from ' . $this->table .' where module=? and catid=?');
		$this->db->set_string($module);
		$this->db->set_string($catid);
		$res = $this->db->execute(true);
		return $res;
	}
	
	function set_conf($params, $module, $catid)
	{
		$this->db->prepare('select count(*) as nums from ' . $this->table .' where module=? and catid=?');
		$this->db->set_string($module);
		$this->db->set_string($catid);
		$res = $this->db->execute(true);
		if(isset($res['nums']) && intval($res['nums']) > 0)
		{
			$res = $this->db->simple_update( $this->table, $params, array( 'catid'=>$catid,'module'=>$module) );
		}
		else 
		{
			if(sizeof($params) != 4)
			{
				return false;
			}
			$params['catid'] = $catid;
			$params['module'] = $module;
			$res = $this->db->insert( $this->table, $params );
			return $res;
		}
	}
	
}
?>